#ifndef CDNPROFILER_H
#define CDNPROFILER_H

#include <windows.h>

//-----------------------------------------------------
/**
* Macros for using the profiler
*/
#ifdef ENABLE_PROFILER

#define PROFILEFRAMESTART()  	prof::CdnProfiler::BeginFrame();
#define PROFILEFRAMEEND()		prof::CdnProfiler::EndFrame();
#define PROFILEFNSTART(name)	prof::CdnProfiler::BeginFn(name);
#define PROFILEFNEND()		    prof::CdnProfiler::EndFn();
#define PROFILEFN(fncall, name)\
		{\
		PROFILEFNSTART(name);\
		fncall;\
		PROFILEFNEND();\
		}
#define PROFILEINIT()			prof::CdnProfiler::Init();
#define PROFILESHUTDOWN()       prof::CdnProfiler::Shutdown();

#else

#define PROFILEFRAMESTART()
#define PROFILEFRAMEEND()
#define PROFILEFNSTART(name)
#define PROFILEFNEND()
#define PROFILEFN(fncall, name)\
		{\
		PROFILEFNSTART(name);\
		fncall;\
		PROFILEFNEND();\
		}
#define PROFILEINIT()
#define PROFILESHUTDOWN()

#endif

//------------------------------------------------------

namespace prof
{
	class CdnProfTimer;
	class CdnProfilerFn;

	class CdnProfiler
	{
	public:

		static void Init();
		static void Shutdown();
		static void BeginFrame();
		static void EndFrame();
		static void BeginFn(const char* name);
		static void EndFn();
		

	private:	

		static bool m_initialized;
		static bool m_frameStarted;
		static CdnProfTimer* m_pFrameTimer;
		static CdnProfilerFn* m_pCurrentFn;

		static float m_totalFrameTime;

		CdnProfiler();
		~CdnProfiler();

		static void PrintFnStats(CdnProfilerFn* fn);
		
	};


	

}


#endif
